package main

import (
	"GoTY/fzf"
	"GoTY/mpv"
	"GoTY/region"
	"GoTY/search"
	"GoTY/subscriptions"
	"os"
	"os/user"
)

func main() {
	const invidious = "https://vid.puffyan.us/"
	choice := []string{"subscriptions", "trends", "search", "add subscription", "import subscriptions", "exit"}

	cur, _ := user.Current()
	currentUser := "/home/" + cur.Username

	r := region.InitRegion(currentUser)
	for {
		author, channel := subscriptions.ShowChannel(currentUser)
		switch fzf.Fzf(choice) {
		case 0:
			s := search.Search(invidious, r, 0, fzf.Fzf(author), channel)
			mpv.OpenVideo(s[fzf.Fzf(s)].VideoId)
		case 1:
			s := search.Search(invidious, r, 1, 0, channel)
			mpv.OpenVideo(s[fzf.Fzf(s)].VideoId)
		case 2:
			s := search.Search(invidious, r, 2, 0, channel)
			mpv.OpenVideo(s[fzf.Fzf(s)].VideoId)
		case 3:
			subscriptions.AppendSub(currentUser)
		case 4:
			subscriptions.ImportSubscription(currentUser)
		case 5:
			os.Exit(0)
		}
	}
}
